import { createTimeColumn, isDisabledColumn } from '@/common/table-columns';
import { BaseColumnType, ClickColumnType } from '@/components/common-table/common-table-type';
import router from '@/router';

const nameCNColumn: ClickColumnType = {
  name: 'click-column',
  prop: 'nameCN',
  label: '量表中文名称',
  width: 260,
  align: 'center',
  handle: (row: any) => {
    router.push({ path: '/scale/info/' + row.id });
  },
};

const nameEnColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'nameEN',
  label: '量表英文名称',
  width: 120,
  align: 'center',
};

const shortNameCNColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'shortNameCN',
  label: '量表中文简称',
  width: 120,
  align: 'center',
};

const shortNameENColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'shortNameEN',
  label: '量表英文简称',
  width: 120,
  align: 'center',
};

const questionNumColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'questionNum',
  label: '题数',
  width: 120,
  align: 'center',
};

const levelColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'level',
  label: '级别',
  width: 120,
  align: 'center',
};

const typeColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'type',
  label: '类型',
  width: 120,
  align: 'center',
};

const isCommonColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'isCommon',
  label: '是否常用',
  width: 120,
  align: 'center',
  formatter: (v) => (!v.isCommon ? '否' : '是'),
};

const authorColumn: BaseColumnType = {
  name: 'base-column',
  prop: 'author',
  label: '作者',
  width: 120,
  align: 'center',
};

export const scaleTableColumns = [
  nameCNColumn,
  nameEnColumn,
  shortNameCNColumn,
  shortNameENColumn,
  questionNumColumn,
  levelColumn,
  typeColumn,
  isCommonColumn,
  isDisabledColumn,
  authorColumn,
  createTimeColumn,
];
